package com.linko.intelligent.remote.core.controller;

import com.linko.intelligent.base.CommonResponse;
import com.linko.intelligent.remote.core.service.DeviceService;
import com.linko.intelligent.remote.pojo.query.DeviceInfoQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author yuan
 * @create 2024/3/15 11:42
 */
@RestController
@RequestMapping("/device")
@Api(value = "DeviceController", tags = "设备和分类")
public class DeviceController {

    @Autowired
    DeviceService deviceService;


    /***
     * 设备分页
     * @param
     * @return
     */
    @ApiOperation("设备列表")
    @GetMapping(value = "/page")
    public CommonResponse page(@Param("query") DeviceInfoQuery query) {
        return new CommonResponse(CommonResponse.SUCCESS, "", deviceService.page(query));
    }

    /***
     * 设备列表
     * @param
     * @return
     */
    @ApiOperation("设备列表")
    @GetMapping(value = "/list")
    public CommonResponse list(@Param("query") DeviceInfoQuery query) {
        return new CommonResponse(CommonResponse.SUCCESS, "", deviceService.deviceList(query));
    }

    /***
     * 设备分类树
     * @param
     * @return
     */
    @ApiOperation("设备分类树")
    @GetMapping(value = "/tree")
    public CommonResponse tree() {
        return new CommonResponse(CommonResponse.SUCCESS, "", deviceService.deviceTree());
    }

    /***
     * 设备详情
     * @param
     * @return
     */
    @ApiOperation("设备详情")
    @GetMapping(value = "/detail")
    public CommonResponse detail(@RequestParam("sn") String sn) {
        return new CommonResponse(CommonResponse.SUCCESS, "", deviceService.deviceDetail(sn));
    }


}
